#ifndef RPIMDUALSOLVCONTEXT_H_
#define RPIMDUALSOLVCONTEXT_H_

#include "graphsupport/solve/facilitylocation/IFacilityLocationSolver.h"
#include "graphsupport/solve/facilitylocation/PrimDualSolvContext.h"

class PrimDualSolvContext
{
public:
	typedef std::vector< FacilitiesGraph::FacilityPricesVecType > RoadPaymentsDataType;

public:
	static const FacilitiesGraph::FacilityPriceType DEFAULT_EPS = 1e-5;

public:
	PrimDualSolvContext(
		int citiesCount = 0,
		int facilitiesCount = 0,
		FacilitiesGraph::FacilityPriceType eps = DEFAULT_EPS
	);

	void initFromGraph();

public:
	FacilitiesGraph fgraph;

public:
	FacilitiesGraph::FacilityPriceType eps;

	FacilitiesGraph::FacilityPriceType getRoadPrice( int city, int fclt );

	FacilitiesGraph::FacilityPriceType getCityPays4road( int city, int fclt );
	FacilitiesGraph::FacilityPriceType getCityPays4total( int city );
	void setCityPays4total( int city, FacilitiesGraph::FacilityPriceType cityPays );
	FacilitiesGraph::FacilityPriceType getPayedForFacility( int facility );

	RoadPaymentsDataType cityPays4fclt;
	Graph specialSubgraph;
	std::vector< char > indepFacilities;
	std::vector< int > associatedFacility;

private:
	void checkCheaperIncomeToFacility( int city, int facility, FacilitiesGraph::FacilityPriceType cityPays );
	bool isXtremeEdge( int city, int facility );

private:
	FacilitiesGraph::FacilityPricesVecType cityPays4total;

private:
	PrimDualSolvContext( const PrimDualSolvContext & );
	void operator = ( const PrimDualSolvContext & );
};

#endif /* RPIMDUALSOLVCONTEXT_H_ */
